home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr11
/
powerb5.zip
/
P5DOS013.TIP
< prev
next >
Wrap
Text File
|
1993-06-01
|
2KB
|
57 lines
One way to allow a batch file to ask a yes or no question is
to have it ask the question, terminate the batch, and let
the user's answer serve as a command that starts the same
batch up again.
Here's a batch file that illustrates the technique. The
batch file asks the user a yes or no question, and two new
batch files are created: Y.BAT and N.BAT. If the user
answers 'Y', then Y.BAT runs, calling the original batch
file again and jumping to the 'Y' routine; if the user
selects 'N', the batch file goes to the 'N' routine. While
the routines here are samples, in real life the batch file
could let the user decide to log on to a server, load
Windows, or whatever.
Emmett A. Dulaney
Muncie, Indiana
Editor's Note: The clever thing about this batch file is the
way it calls itself indirectly using a pair of temporary
batch files. I've changed Mr. Dulaney's original batch so
that the question actually becomes the DOS prompt; DOS
continues to ask the question until the user types 'Y' or
'N'. If you want to modify the batch (shown below) for your
own use, you can extract it to a file using the Alt-F
command.
---- BEGIN LISTING ----
@ECHO OFF
IF NOT "%1"=="" GOTO %1
SET | FIND "PROMPT=" > OLDPROMP.BAT
PROMPT Do you wish to answer Yes or No? [Y/N]
ECHO @CONFIRM Y > Y.BAT
ECHO @CONFIRM N > N.BAT
GOTO STOP
:Y
REM Commands for a "Yes" choice
ECHO You answered Yes to the question.
GOTO END
:N
REM Commands for a "No" choice
ECHO You answered No to the question.
:END
OLDPROMP
DEL Y.BAT
DEL N.BAT
:STOP
---- END LISTING ----
Title: Confirm or Deny
Category: DOS
Issue Date: December, 1992
Editor: Brett Glass
Supplementary Files: None
Filename: P5DOS013.TIP